Page({
  data: {
    //摄像头位置
    devicePosition: 'back'
  },
  onLoad(options) {},
  /**
   * 跳转
   */
  //用户详情
  to_user_desc() {
    wx.navigateTo({
      url: '/pages/user/desc/desc',
    })
  },
  /**
   * 拍摄
   */
  //1.切换摄像头
  onChangeCamera() {
    if (this.data.devicePosition == "back") {
      this.setData({
        devicePosition: "front"
      })
    } else {
      this.setData({
        devicePosition: "back"
      })
    }
  },
  //2.拍摄
  takePhotoHandle() {
    const ctx = wx.createCameraContext()
    ctx.takePhoto({
      quality: 'high',
      success: (res) => {
        this.setData({
          info: res.tempImagePath,
        })
        //跳转到照片页面
        wx.navigateTo({
          url: '/pages/user/desc/camera/img_take/img_take?img?=' + res.tempImagePath,
        })
      }
    })
  },
})